unit UCadEtapaDetalheMaterial;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UModeloFilha, DB, DBTables, StdCtrls, Buttons, Mask, DBCtrls, UDPTOUteis;

type
  TFCadEtapaDetalheMaterial = class(TFModeloFilha)
    intgrfldFilhaIDMATERIAL: TIntegerField;
    intgrfldFilhaETPDETID: TIntegerField;
    intgrfldFilhaETPID: TIntegerField;
    intgrfldFilhaEMPREENDID: TIntegerField;
    lbl1: TLabel;
    dbedtIDMATERIAL: TDBEdit;
    ds1: TDataSource;
    EdDescMaterial: TEdit;
    procedure dbedtIDMATERIALDblClick(Sender: TObject);
    procedure dbedtIDMATERIALExit(Sender: TObject);
    procedure qFilhaAfterScroll(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FCadEtapaDetalheMaterial: TFCadEtapaDetalheMaterial;

implementation

uses UPesqMaterial;

{$R *.dfm}

procedure TFCadEtapaDetalheMaterial.dbedtIDMATERIALDblClick(
  Sender: TObject);
begin
  inherited;
  dbedtIDMATERIAL.Text := DPTOChamaPesquisa(FPesqMaterial,TFPesqMaterial,'IDMATERIAL', qfilha, dbedtIDMATERIAL.Text);
end;

procedure TFCadEtapaDetalheMaterial.dbedtIDMATERIALExit(Sender: TObject);
begin
  inherited;

  IF dbedtIDMATERIAL.Text <> '' THEN
  BEGIN
    qgenerica.Close;
    qGenerica.SQL.Clear;
    qGenerica.SQL.Add('SELECT MATDESCRICAO FROM MATERIAIS WHERE IDMATERIAL = ' + QuotedStr(dbedtIDMATERIAL.Text ));
    qGenerica.Open;


    EdDescMaterial.Text := qGenerica.FieldByName('MATDESCRICAO').ASSTRING;
  END
  ELSE EdDescMaterial.Text := '';

end;

procedure TFCadEtapaDetalheMaterial.qFilhaAfterScroll(DataSet: TDataSet);
begin
  inherited;
  IF qFilha.FieldByName('IDMATERIAL').AsString <> '' THEN
  BEGIN
    qgenerica.Close;
    qGenerica.SQL.Clear;
    qGenerica.SQL.Add('SELECT MATDESCRICAO FROM MATERIAIS WHERE IDMATERIAL = ' + QuotedStr(qFilha.FieldByName('IDMATERIAL').AsString));
    qGenerica.Open;


    EdDescMaterial.Text := qGenerica.FieldByName('MATDESCRICAO').ASSTRING;
  END
  ELSE EdDescMaterial.Text := '';
end;

end.
